package com.voxel.sense.infomsg.widget.adapter;

import android.view.View;
import android.widget.TextView;

import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.data.bean.ConditionBean;
import cyy.example.com.facotry.Factory;

import java.util.List;

/**
 * Created by ChenYiYao on 2018/9/7.
 */
public class TextFilterRecyclerAdapter extends AbsPickRecyclerAdapter {

    public TextFilterRecyclerAdapter() {
        this(null);
    }

    @Override
    protected boolean handlerSatu(ConditionBean conditionBean) {
        return true;
    }

    public TextFilterRecyclerAdapter(AdapterListener<ConditionBean> listener) {
        super(listener);
    }

    public TextFilterRecyclerAdapter(List<ConditionBean> conditionBeans, AdapterListener<ConditionBean> listener) {
        super(conditionBeans, listener);
    }

    @Override
    protected int getItemViewType(int position, ConditionBean bean) {
        return R.layout.item_list_drop_down;
    }

    @Override
    protected ViewHolder<ConditionBean> onCreateViewHolder(View root, int viewType) {
        return new ItemViewHolder(root);
    }

    static class ItemViewHolder extends ViewHolder<ConditionBean> {

        TextView mText;
        View root;

        public ItemViewHolder(View itemView) {
            super(itemView);
            root = itemView;
            this.mText = (TextView) itemView.findViewById(R.id.text);
        }

        @Override
        protected void onBind(ConditionBean conditionBean) {
            mText.setText(conditionBean.getDesc());
            if (conditionBean.isSelect()) {//切换状态
                mText.setTextColor(Factory.app().getResources().getColor(R.color.drop_down_selected));
                mText.setCompoundDrawablesWithIntrinsicBounds(Factory.app().getResources().
                        getDrawable(R.mipmap.icon_select), null, null, null);
            } else {//未选状态
                mText.setTextColor(Factory.app().getResources().getColor(R.color.drop_down_unselected));
                mText.setCompoundDrawablesWithIntrinsicBounds(Factory.app().getResources().
                        getDrawable(R.mipmap.select_user_unclick), null, null, null);
            }
        }
    }

}
